<<<<<<< HEAD
<template>
    <div id="addProvider">
        <table>
            <tr>
                <td>单据类型</td>
                <td><el-select v-model="receipt.receiptTypeId" placeholder="类别">
                        <el-option v-for="item in list" :key="item.receiptTypeId" :label="item.receiptTypeName"
                            :value="item.receiptTypeId"></el-option>

                    </el-select></td>
                <td>规则名称</td>
                <td><el-input v-model="receipt.receiptName"></el-input></td>
            </tr>
            <br>
            <tr>
                <td>编码前缀</td>
                <td><el-input v-model="receipt.receiptPre"></el-input></td>
            </tr>
            <br>
            <tr>
                <td>范例</td>
                <td><el-input v-model="getExample" disabled></el-input></td>
                <td><input type="checkbox" @change="isdefault()">是否设为默认</td>

            </tr>
            <br>
            <tr>
                <td></td>
                <td><el-button style="margin-left: 170px" type="primary" @click="insert()">新增</el-button></td>
            </tr>
            <br>
        </table>

    </div>
</template>

<script>
import axios from 'axios';



export default {
    name: 'AddProvider',
    data() {
        return {
            list: [],
            receipt: {
                now: "",
                receiptName: "",
                receiptTypeId: "",
                receiptPre: "",
                example1: "001",
                example: "",
                isDefault: 0
            }
        }
    },
    computed: {
        getExample() {
            return this.receipt.example = this.receipt.receiptPre + this.receipt.now + this.receipt.example1
        }
    },
    methods: {
        insert: function () {
            // alert(this.receipt.receiptTypeId)
            // return
            if (this.receipt.receiptName === "") {
                alert("规则名称不能为空")
                return
            }
            if (this.receipt.receiptTypeId === 0) {
                alert("请选择单据类型")
                return
            }
            if (this.receipt.receiptPre === "") {
                alert("编码前缀不能为空")
                return
            }
            axios.post(
                "/info/receipt/insert",
                this.receipt
            ).then(rs => {
                console.log(rs)
            })
        },
        isdefault: function () {
            this.receipt.isDefault = 1
        },
        getType: function () {
            this.axios({
                url: "/info/receipttype/selectAll"
            }).then(rs => {
                console.log(rs)
                this.list = rs.data.list
                var now = new Date();

                var year = now.getFullYear();

                // 获取月份（注意月份是从0开始的，所以需要加1）
                var month = now.getMonth() + 1;

                // 获取日期
                var day = now.getDate();
                this.receipt.now = year + "" + month + "" + day
                console.log(this.now)
            })
        }
    },
    created: function () {

        this.getType()
    }
}
</script>

<style scoped>
#addProvider {
    width: 100%;
    height: 450px;

    /* background-color: pink; */
}

#contact {
    width: 90%;
    margin: auto;
    border-collapse: collapse;
    color: #707276;
}

#contact th,
#contact td {
    border: 1px #c0c4cc solid;
    height: 35px;
    min-width: 30px;
}

p {
    color: #4b4a4a;
    font-size: 18px;

}

.el-input {
    width: 240px;
}

table td :not([id=contact]) {
    text-align: left;
    padding-right: 10px;
    /* padding-top: 10px;
    padding-bottom: 10px; */
}

td:nth-child(odd) {
    text-align: center;
    padding-right: 10px;
}
=======
<template>
    <div id="addProvider">
        <table>
            <tr>
                <td>单据类型</td>
                <td><el-select v-model="receipt.receiptTypeId" placeholder="类别">
                        <el-option v-for="item in list" :key="item.receiptTypeId" :label="item.receiptTypeName"
                            :value="item.receiptTypeId"></el-option>

                    </el-select></td>
                <td>规则名称</td>
                <td><el-input v-model="receipt.receiptName"></el-input></td>
            </tr>
            <br>
            <tr>
                <td>编码前缀</td>
                <td><el-input v-model="receipt.receiptPre"></el-input></td>
            </tr>
            <br>
            <tr>
                <td>范例</td>
                <td><el-input v-model="getExample" disabled></el-input></td>
                <td><input type="checkbox" @change="isdefault()">是否设为默认</td>

            </tr>
            <br>
            <tr>
                <td></td>
                <td><el-button style="margin-left: 170px" type="primary" @click="insert()">新增</el-button></td>
            </tr>
            <br>
        </table>

    </div>
</template>

<script>
import axios from 'axios';



export default {
    name: 'AddProvider',
    data() {
        return {
            list: [],
            receipt: {
                now: "",
                receiptName: "",
                receiptTypeId: "",
                receiptPre: "",
                example1: "001",
                example: "",
                isDefault: 0
            }
        }
    },
    computed: {
        getExample() {
            return this.receipt.example = this.receipt.receiptPre + this.receipt.now + this.receipt.example1
        }
    },
    methods: {
        insert: function () {
            // alert(this.receipt.receiptTypeId)
            // return
            if (this.receipt.receiptName === "") {
                alert("规则名称不能为空")
                return
            }
            if (this.receipt.receiptTypeId === 0) {
                alert("请选择单据类型")
                return
            }
            if (this.receipt.receiptPre === "") {
                alert("编码前缀不能为空")
                return
            }
            axios.post(
                "/info/receipt/insert",
                this.receipt
            ).then(rs => {
                console.log(rs)
            })
        },
        isdefault: function () {
            this.receipt.isDefault = 1
        },
        getType: function () {
            this.axios({
                url: "/info/receipttype/selectAll"
            }).then(rs => {
                console.log(rs)
                this.list = rs.data.list
                var now = new Date();

                var year = now.getFullYear();

                // 获取月份（注意月份是从0开始的，所以需要加1）
                var month = now.getMonth() + 1;

                // 获取日期
                var day = now.getDate();
                this.receipt.now = year + "" + month + "" + day
                console.log(this.now)
            })
        }
    },
    created: function () {

        this.getType()
    }
}
</script>

<style scoped>
#addProvider {
    width: 100%;
    height: 450px;

    /* background-color: pink; */
}

#contact {
    width: 90%;
    margin: auto;
    border-collapse: collapse;
    color: #707276;
}

#contact th,
#contact td {
    border: 1px #c0c4cc solid;
    height: 35px;
    min-width: 30px;
}

p {
    color: #4b4a4a;
    font-size: 18px;

}

.el-input {
    width: 240px;
}

table td :not([id=contact]) {
    text-align: left;
    padding-right: 10px;
    /* padding-top: 10px;
    padding-bottom: 10px; */
}

td:nth-child(odd) {
    text-align: center;
    padding-right: 10px;
}
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
</style>